package com.youlin.config;

import com.youlin.aop.CrossFilter;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.core.session.SessionRegistry;
import org.springframework.security.core.session.SessionRegistryImpl;
import javax.servlet.Filter;
import java.util.Arrays;

@Configuration
public class ConfigBean {

	@Bean
	public FilterRegistrationBean myCrossFilter (){
		FilterRegistrationBean registrationBean = new FilterRegistrationBean();
		registrationBean.setFilter(this.CrossFilter());
		registrationBean.setUrlPatterns(Arrays.asList("/*"));
//		registrationBean.setOrder(Integer.MAX_VALUE);
		return registrationBean;
	}

	@Bean
	public Filter CrossFilter () {
		return new CrossFilter();
	}

	@Bean
	public SessionRegistry sessionRegistry() {
		return new SessionRegistryImpl();
	}

}